<%-- 
    Document   : calendario
    Created on : 4/09/2009, 03:26:28 PM
    Author     : josue
--%>

<%@page session="true" import="java.util.*" %>
<%
// JSP Calendar:--
// Created by Jason Benassi
// jbenassi@lime-light.com
// http://www.wakeboardutah.com
// 7-2002
%>
<%
// Global Vars
            int action = 0;  // incoming request for moving calendar up(1) down(0) for month
            int currYear = 0; // if it is not retrieved from incoming URL (month=) then it is set to current year
            int currMonth = 0; // same as year
            String boxSize = "50";  // how big to make the box for the calendar

//build 2 calendars

            Calendar c = Calendar.getInstance();
            Calendar cal = Calendar.getInstance();
            
            if (request.getParameter("action") == null) // Check to see if we should set the year and month to the current
            {
                currMonth = c.get(c.MONTH);

                currYear = c.get(c.YEAR);
                cal.set(currYear, currMonth, 1);

            } else {
                if (!(request.getParameter("action") == null)) // Hove the calendar up or down in this if block
                {
                    currMonth = Integer.parseInt(request.getParameter("month"));
                    currYear = Integer.parseInt(request.getParameter("year"));

                    if (Integer.parseInt(request.getParameter("action")) == 1) {
                        cal.set(currYear, currMonth, 1);
                        cal.add(cal.MONTH, 1);
                        currMonth = cal.get(cal.MONTH);
                        currYear = cal.get(cal.YEAR);
                    } else {
                        cal.set(currYear, currMonth, 1);
                        cal.add(cal.MONTH, -1);
                        currMonth = cal.get(cal.MONTH);
                        currYear = cal.get(cal.YEAR);
                    }
                }
            }
%>

<%!
    public boolean isDate(int m, int d, int y) // This method is used to check for a VALID date
    {
        m -= 1;
        Calendar c = Calendar.getInstance();
        c.setLenient(false);

        try
        {
                c.set(y,m,d);
                Date dt = c.getTime();
        }
          catch (IllegalArgumentException e)
        {
                return false;

        }
                return true;
    }
%>
<%!
   public String getDateName (int monthNumber) // This method is used to quickly return the proper name of a month
   {
                String strReturn = "";
                switch (monthNumber)
                {
        case 0:
                strReturn = "Enero";
                break;
        case 1:
                strReturn = "Febrero";
                break;
        case 2:
                strReturn = "Marzo";
                break;
        case 3:
                strReturn = "Abril";
                break;
        case 4:
                strReturn = "Mayo";
                break;
        case 5:
                strReturn = "Junio";
                break;
        case 6:
                strReturn = "Julio";
                break;
        case 7:
                strReturn = "Agosto";
                break;
        case 8:
                strReturn = "Septiembre";
                break;
        case 9:
                strReturn = "Octubre";
                break;
        case 10:
                strReturn = "Noviembre";
                break;
        case 11:
                strReturn = "Diciembre";
                break;
        }
        return strReturn;
    }
%>


       
        
       
  


!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Agenda EDD</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-2" />
<link rel="stylesheet" href="images/style.css" type="text/css" />
</head>
<body>
<div class="content">
  <div class="preheader">
    <div class="padding"> <a href="http://www.free-css.com/">About</a>&nbsp; <a href="http://www.free-css.com/">Contact</a> </div>
  </div>
  <div class="header">
    <div class="title">AGENDA FX</div>
    <div class="slogan">MAKING YOUR LIFE EASY</div>
  </div>
  <div id="nav">
    <ul>
      <li><a href="index.jsp">Home</a></li>
      <li><a href="calendario.jsp">Calendario</a></li>
      <li><a href="Contactos.jsp">Contactos</a></li>
      <li><a href="http://www.free-css.com/">Affiliates</a></li>
      <li id="current"><a href="http://www.free-css.com/">About</a></li>
      <li><a href="http://www.free-css.com/">Contact</a></li>
    </ul>
  </div>
  <div class="main_content">
    <div class="sd_right">
      <div class="text_padding">
        <h2></h2>
         <br />
        <h2>Cargar Contactos XML</h2>
        <form method="post" action="/proyectoEDD/calendarioServlet"   enctype="multipart/form-data">
          <p>
            <input type="file" name="fichero"  />
            <input type="submit" value="Upload"  />
          </p>
        </form>
        <br />
        <h2>Last Articles</h2>
        <a href="http://www.free-css.com/">Link to a article</a><br />
        <a href="http://www.free-css.com/">Link to another article...</a><br />
        <br />
        <h2>Links</h2>
        <a href="http://www.free-css.com/">www.solucija.com</a><br />
        <a href="http://www.free-css.com/">ww.free-css-templates.com</a><br />
      </div>
    </div>
    <div class="sd_left">
      <div class="text_padding">
        <h2></h2>
         <center>
        <table border='1' width='519' celpadding='0' cellspacing='0'>
            <tr>
                <td width='150' align='right' valign='middle'><a href="cal.jsp?month=<%=currMonth%>&year=<%=currYear%>&action=0"><font size="1">Mes Anterior</font></a></td>
                <td width='260' align='center' valign='middle'><b><font color="black"><%=getDateName(cal.get(cal.MONTH)) + " " + cal.get(cal.YEAR)%></font></b></td>
                <td width='173' align='left' valign='middle'><a href="cal.jsp?month=<%=currMonth%>&year=<%=currYear%>&action=1"<font size="1">Mes Siguiente</font></a></td>
            </tr>
        </table>
        <table border="0" width="520" bordercolorlight="#C0C0C0" bordercolordark="#808080" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">
            <td width="100%">
                <table border="2" width="519" bordercolorlight="#C0C0C0" bordercolordark="#000000" style="border-collapse: collapse" bordercolor="#000000" cellpadding="0" cellspacing="0" bgcolor="#DFDCD8">
                    <tr>
                        <td width="<%=boxSize%>" align="center" nowrap bordercolor="#666666" bgcolor="#666666">
                            <font color="#FFFFFF"><b>Domingo</b></font></td>
                        <td width="<%=boxSize%>" align="center" nowrap bordercolor="#666666" bgcolor="#666666">
                            <font color="#FFFFFF"><b>Lunes</b></font></td>
                        <td width="<%=boxSize%>" align="center" nowrap bordercolor="#666666" bgcolor="#666666">
                            <font color="#FFFFFF"><b>Martes</b></font></td>
                        <td width="<%=boxSize%>" align="center" nowrap bordercolor="#666666" bgcolor="#666666">
                            <font color="#FFFFFF"><b>Miercoles</b></font></td>
                        <td width="<%=boxSize%>" align="center" nowrap bordercolor="#666666" bgcolor="#666666">
                            <font color="#FFFFFF"><b>Jueves</b></font></td>
                        <td width="<%=boxSize%>" align="center" nowrap bordercolor="#666666" bgcolor="#666666">
                            <font color="#FFFFFF"><b>Viernes</b></font></td>
                        <td width="<%=boxSize%>" align="center" nowrap bordercolor="#666666" bgcolor="#666666">
                            <font color="#FFFFFF"><b>Sabado</b></font></td>
                    </tr>
                    <%

                    //'Calendar loop


                                int currDay;
                                String todayColor;
                                int count = 1;
                                int dispDay = 1;


                                for (int w = 1; w < 7; w++) {
                    %>
                    <tr>
                        <%
                                    for (int d = 1; d < 8; d++) {
                                        if (!(count >= cal.get(c.DAY_OF_WEEK))) {

                        %>
                        <td width="<%=boxSize%>" height="<%=boxSize%>" valign="top" align="left">&nbsp;</td>
                        <%
                                                    count += 1;
                                                } else {

                                                    if (isDate(currMonth + 1, dispDay, currYear)) // use the isDate method
                                                    {

                                                        if (dispDay == c.get(c.DAY_OF_MONTH) && c.get(c.MONTH) == cal.get(cal.MONTH) && c.get(c.YEAR) == cal.get(cal.YEAR)) // Here we check to see if the current day is today
                                                        {
                                                            todayColor = "#6C7EAA";
                                                        } else {
                                                            todayColor = "#ffffff";
                                                        }
                        %>
                        <td bgcolor ="<%=todayColor%>" width="<%=boxSize%>" align="left" height="<%=boxSize%>" valign="top"><a href="/proyectoEDD/calendarioServlet?dia=<%=dispDay%>&mes=<%=currMonth+1%>&ano=<%=currYear%>&pase=0"><%=dispDay%></a><br>
                        </td>
                        <%
                                                            count += 1;
                                                            dispDay += 1;
                                                        } else {
                        %>
                        <td width="<%=boxSize%>" align="left" height="<%=boxSize%>" valign="top">&nbsp;</td>
                        <%
                                            }
                                        }

                                    }
                        %>
                    </tr>
                    <%
                                }
                    %>
                </table>
            </td>
            <tr><td>
        </table>
    </center>
        <p class="date"><img src="images/comment.gif" alt="" /> <a class="date" href="http://www.free-css.com/">Comments(2)</a> <img src="images/timeicon.gif" alt="" /> 21.02.</p>
        <br />

        <p class="date"><img src="images/comment.gif" alt="" /> <a class="date" href="http://www.free-css.com/">Comments(15)</a> <img src="images/timeicon.gif" alt="" /> 13.01.</p>
        <br />
      </div>
    </div>
    <div class="footer">
      <div class="padding"> Powered by <a href="http://snews.solucija.com" title="Single file CSS and XHTML valid CMS">sNews</a> | &copy; Copyright BinaryNews Template :: Design: <a href="http://www.free-css-templates.com/" title="Free CSS Templates">David Herreman</a> | <a href="rss/">RSS Feed</a> | <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a> and <a href="http://validator.w3.org/check?uri=referer">XHTML</a> | <a href="http://www.free-css.com/">Login</a> </div>
    </div>
  </div>
</div>
</body>
</html>
